﻿@using Huirui.Cavan.Domain.MainBoundedContext.SystemModule
@model Huirui.Cavan.Presentation.ViewModel.SystemModule.ICorporationViewModel
@{Layout = null;}
@using (Html.BeginForm(ActionConst.ADD, ControllerConst.CORPORATION, FormMethod.Post))
{
    <div class="tool_bar">
        <input id="company_save" type="submit" style="display: none;" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'" onclick="javascript:$('#company_save').click()">保存</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label>公司编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.Id, new { id = "company_code", disabled = Model.Item.Id.IsNullOrEmpty() ? false:true })
                @Html.HiddenFor(m => m.Item.Id)
            </td>
            <td class="c100">
                <label>所属行业:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.Item.Industry.Id, Model.IndustryList, "请选择行业类型", new { id = "industry_type" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>公司名称:</label>
            </td>
            <td colspan="3">
                @Html.TextBoxFor(m => m.Item.Name, new { id = "company_cn_name" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>所在区域:</label>
            </td>
            <td class="c160" colspan="3">
                @{ Html.RenderAction(ActionConst.SELECTAREA, ControllerConst.AREA, new { purpose = "ForCorporation", cityID = @Model.CityID, provinceID = @Model.ProvinceID }); }
                @Html.HiddenFor(m => m.Item.Area.Id, new { id = "areaForCorporation" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>公司名称(英文):</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.EnglishName, new { id = "company_en_name" })
            </td>
            <td class="c100">
                <label>公司Logo:</label>
            </td>
            <td class="c160">
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>服务类型:</label>
            </td>
            <td class="c160">
                <select name="salesman_type">
                    <option value="0" selected="selected">进销存</option>
                    <option value="1">会计</option>
                </select>
            </td>
            <td class="c100">
                <label>最大用户数:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.Item.MaxUser, new { id = "max_users", disabled = "disabled" })
            </td>
        </tr>
    </table>

    <fieldset>
        <legend>联系方式</legend>
        <table class="form_heard">
            <tr>
                <td class="c100">
                    <label>联系人:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Contact, new { id = "contact" })
                </td>
                <td class="c100">
                    <label>公司网址:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Website, new { id = "company_website" })
                </td>
                <td class="c100">
                    <label>电话号码:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Mobile, new { id = "mobile" })
                </td>
                <td class="c100">
                </td>
                <td class="c160">
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>手机号码:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Telephone, new { id = "telephone" })
                </td>
                <td class="c100">
                    <label>传真号码:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Fax, new { id = "fax" })
                </td>
                <td class="c100">
                    <label>Email:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Email, new { id = "email" })
                </td>
                <td class="c100">
                </td>
                <td class="c160">
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>通讯地址(中文):</label>
                </td>
                <td class="c160" colspan="7">
                    @Html.TextBoxFor(m => m.Item.Address, new { id = "cn_address" })
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>通讯地址(英文):</label>
                </td>
                <td class="c160" colspan="7">
                    @Html.TextBoxFor(m => m.Item.AddressEnglish, new { id = "en_address" })
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>送货地址1:</label>
                </td>
                <td class="c160" colspan="7">
                    @Html.TextBoxFor(m => m.Item.DeliveryAddress1, new { id = "deliveryAddress1" })
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>送货地址2:</label>
                </td>
                <td class="c160" colspan="7">
                    @Html.TextBoxFor(m => m.Item.DeliveryAddress2, new { id = "deliveryAddress2" })
                </td>
            </tr>
            <tr>
                <td class="c100">
                    <label>送货地址3:</label>
                </td>
                <td class="c160" colspan="7">
                    @Html.TextBoxFor(m => m.Item.DeliveryAddress3, new { id = "deliveryAddress3" })
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend>会计属性</legend>
        <table class="form_heard">
            <tr>
                <td class="c100">
                    <label>纳税识别号:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.TaxIdentificationNumber, new { id = "tax_id" })
                </td>
                <td class="c100">
                    <label>开户银行:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.Bank, new { id = "bank_name" })
                </td>
                <td class="c100">
                    <label>开户账号:</label>
                </td>
                <td class="c160">
                    @Html.TextBoxFor(m => m.Item.BankAccount, new { id = "bank_no" })
                </td>
            </tr>
        </table>
    </fieldset>
}
@*@{ Html.RenderAction(ActionConst.ADD, ControllerConst.INDUSTRYTYPE); }*@
<script type="text/javascript">
    $(function ()
    {
        $("form[action^='/corporation/']").submit(function ()
        {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (data)
                {
                    if (data)
                    {
                        alert(data.Messages[0]);
                    }
                },
                error: function ()
                {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });

//        $("select#industry_type").bind("change", function ()
//        {
//            if ($(this).val() == "-1")
//            {
//                openWindow("addIndustryType");
//            }
//        });

//        $("form[action^='/industrytype/add']").submit(function ()
//        {
//            $("#areaForCorporation").val($("#cityForCorporation").val()); 
//            $.ajax({
//                url: this.action,
//                type: this.method,
//                data: $(this).serialize(),
//                success: function (data)
//                {
//                    if (data)
//                    {
//                        $("select#industry_type option").each(function ()
//                        {
//                            if ($(this).val() == "-1")
//                            {
//                                $(this).remove();
//                            }
//                        });
//                        $("<option value='" + data.Messages[0] + "'>" + data.Messages[1] + "</option>").appendTo($("select#industry_type"));
//                        $("<option value='-1'>添加...</option>").appendTo($("select#industry_type"));
//                        $("select#industry_type").attr("value", data.Messages[0]);
//                        closeWindow("addIndustryType");
//                    }
//                },
//                error: function ()
//                {
//                    alert('系统繁忙，请稍候再试');
//                }
//            })

//            return false;
//        });

        $("#provinceForCorporation").bind("change", function () { getSelectItem($("#provinceForCorporation").val(), $("#cityForCorporation")) });
//        $("#cityForCorporation").bind("change", function () { getAreaValue("areaForCorporation", $(this).val()) });
    })
</script>
